﻿using Microsoft.Extensions.Configuration;
using System.IO;
namespace MyFramework.Core.Configuration
{
    /// <summary>
    /// 
    /// </summary>
    public class ConfigurationHelper
    {
        private static IConfiguration config;
        /// <summary>
        /// 
        /// </summary>
        public static IConfiguration Configuration//加载配置文件
        {
            get
            {
                if (config != null) return config;
                config = new ConfigurationBuilder()//nuget Microsoft.Extensions.Configuration
                    .SetBasePath(Directory.GetCurrentDirectory())//nuget Microsoft.Extensions.Configuration.FileExtensions
                    .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)//Microsoft.Extensions.Configuration.Json
                    .Build();
                return config;
            }
            set => config = value;
        }
    }
}